//package com.per.mybootall.rabbitmq;
//
//import com.rabbitmq.client.Channel;
//
//import org.springframework.amqp.core.Message;
//
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.io.IOException;
//
///**
// * 消费者
// * */
//@Component
//public class RabbitMqConsumer {
//    @Resource
//    private RabbitTemplate rabbitTemplate;
//
//    @RabbitListener(queues = "newQueue")
//    public void topicConsumer(Message message,Channel channel) throws IOException {
//        System.out.println("业务消费===>>>>>"+new String(message.getBody(),"utf-8"));
//
//        //确认消费===>>确认完成则删除   [false:    true:]
//        channel.basicAck(message.getMessageProperties().getDeliveryTag(),true);
//
//        //拒绝接收===>>>>>直接将消息进入死信队列
//         //channel.basicNack(message.getMessageProperties().getDeliveryTag(),false,false);
//    }
//
//    @RabbitListener(queues = "dieQueue")
//    public void dietopicConsumer(Message message,Channel channel) throws IOException {
//        System.out.println("死信消费======>>>>>>>");
//        System.out.println(new String(message.getBody()));
//
//        channel.basicNack(message.getMessageProperties().getDeliveryTag(),false,false);
//    }
//
//}
